﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cinch;
using System.ComponentModel;
using System.ComponentModel.Composition;

namespace Anata.Client
{
    /// <summary>
    /// Represents a single Image ViewModel
    /// </summary>
    public class TransaksiProdukThumbnailViewModel : ViewModelBase
    {
        #region Data

        //private ViewMode currentViewMode = ViewMode.AddMode;

        #region Data.Primitives
        private Int32 idTransaksiProduk;
        private Int32? idTransaksi;
        private Int32? idJenisStok;
        private String namaJenisStok;
        private Int32? idKaryawan;
        private String namaKaryawan;
        private Int32 jumlahProduk;
        private Int32 hargaProduk;
        private Int32 potonganHarga;
        private Int32 komisiKaryawan;
        private Boolean isBatal;
        private DateTime? waktuBatal;
        #endregion

        //private IEnumerable<DataWrapperBase> cachedListOfDataWrappers;

        #region Data.Rules
        #endregion

        #region Data.VMs
        #endregion

        #region Data.Services
        #endregion

        #endregion

        #region Constructor
        public TransaksiProdukThumbnailViewModel()
        {
            #region Constructor.SetupServices
            #endregion

            #region Constructor.SetupCommands
            #endregion

            #region Constructor.SetupDataWrappers
            #endregion

            //fetch list of all DataWrappers, so they can be used again later without the
            //need for reflection
            //cachedListOfDataWrappers =
            //    DataWrapperHelper.GetWrapperProperties<TransaksiProdukThumbnailViewModel>(this);

            #region Constructor.SetupValidationRules
            #endregion

            #region Constructor.SetupCollections
            #endregion
        }
        #endregion

        #region Static
        #endregion

        #region Public Properties

        #region Public.Commands
        #endregion

        #region Public.ViewMode
        #endregion

        #region Public.Data
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idTransaksiProdukChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.IdTransaksiProduk);
        public Int32 IdTransaksiProduk
        {
            get { return idTransaksiProduk; }
            set
            {
                idTransaksiProduk = value;
                NotifyPropertyChanged(idTransaksiProdukChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idTransaksiChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.IdTransaksi);
        public Int32? IdTransaksi
        {
            get { return idTransaksi; }
            set
            {
                idTransaksi = value;
                NotifyPropertyChanged(idTransaksiChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idJenisStokChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.IdJenisStok);
        public Int32? IdJenisStok
        {
            get { return idJenisStok; }
            set
            {
                idJenisStok = value;
                NotifyPropertyChanged(idJenisStokChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaJenisStokChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.NamaJenisStok);
        public String NamaJenisStok
        {
            get { return namaJenisStok; }
            set
            {
                namaJenisStok = value;
                NotifyPropertyChanged(namaJenisStokChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs hargaProdukChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.HargaProduk);
        public Int32 HargaProduk
        {
            get { return hargaProduk; }
            set
            {
                hargaProduk = value;
                NotifyPropertyChanged(hargaProdukChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs jumlahProdukChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.JumlahProduk);
        public Int32 JumlahProduk
        {
            get { return jumlahProduk; }
            set
            {
                jumlahProduk = value;
                NotifyPropertyChanged(jumlahProdukChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs idKaryawanChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.IdKaryawan);
        public Int32? IdKaryawan
        {
            get { return idKaryawan; }
            set
            {
                idKaryawan = value;
                NotifyPropertyChanged(idKaryawanChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs namaKaryawanChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.NamaKaryawan);
        public String NamaKaryawan
        {
            get { return namaKaryawan; }
            set
            {
                namaKaryawan = value;
                NotifyPropertyChanged(namaKaryawanChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs komisiKaryawanChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.KomisiKaryawan);
        public Int32 KomisiKaryawan
        {
            get { return komisiKaryawan; }
            set
            {
                komisiKaryawan = value;
                NotifyPropertyChanged(komisiKaryawanChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs potonganHargaChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.PotonganHarga);
        public Int32 PotonganHarga
        {
            get { return potonganHarga; }
            set
            {
                potonganHarga = value;
                NotifyPropertyChanged(potonganHargaChangeArgs);
            }
        }

        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs isBatalChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.IsBatal);
        public Boolean IsBatal
        {
            get { return isBatal; }
            set
            {
                isBatal = value;
                NotifyPropertyChanged(isBatalChangeArgs);
            }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs waktuBatalChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.WaktuBatal);
        public DateTime? WaktuBatal
        {
            get { return waktuBatal; }
            set
            {
                waktuBatal = value;
                NotifyPropertyChanged(waktuBatalChangeArgs);
            }
        }
        #endregion

        #region Public.Cached Collection
        #endregion

        #region Public.DataVM
        #endregion

        #region Public.SummaryData
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs subTotalHargaProdukChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.SubTotalHargaProduk);
        public Int32 SubTotalHargaProduk
        {
            get { return JumlahProduk * HargaProduk; }
        }
        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs totalHargaProdukChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukThumbnailViewModel>(x => x.TotalHargaProduk);
        public Int32 TotalHargaProduk
        {
            get { return SubTotalHargaProduk - PotonganHarga; }
        }

        /// <summary>
        /// </summary>
        static PropertyChangedEventArgs statusTransaksiProdukChangeArgs =
            ObservableHelper.CreateArgs<TransaksiProdukViewModel>(x => x.StatusTransaksiProduk);
        public int StatusTransaksiProduk
        {
            get
            {
                int retval = 0;
                if (isBatal)
                {
                    retval = TransaksiProdukViewModel.STATUS_TRANSAKSIPRODUK_CANCELLED;
                }
                else
                {
                    retval = TransaksiProdukViewModel.STATUS_TRANSAKSIPRODUK_OK;
                }
                return retval;
            }
        }
        #endregion

        #endregion

        #region Command Handlers
        #endregion

        #region Change Callbacks
        #endregion

        #region Private Methods
        #endregion

        #region Overrides
        public override string ToString()
        {
            return String.Format("TransaksiProdukThumbnailViewModel {0}", this.idTransaksiProduk);
        }
        #endregion

        #region EditableValidatingViewModelBase overrides
        #endregion
    }
}
